﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Abc.Database.Migrations.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AutidLog",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Table = table.Column<string>(type: "TEXT", nullable: true, comment: "表名"),
                    DataId = table.Column<string>(type: "TEXT", nullable: true, comment: "ID，主键ID"),
                    Content = table.Column<string>(type: "TEXT", nullable: true, comment: "内容"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "操作时间"),
                    UserId = table.Column<int>(type: "INTEGER", nullable: false, comment: "操作人ID"),
                    UserName = table.Column<string>(type: "TEXT", nullable: true, comment: "操作人账户名"),
                    Operate = table.Column<string>(type: "TEXT", nullable: true, comment: "操作方式：新增、更新、删除")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AutidLog", x => x.Id);
                },
                comment: "审计日志");

            migrationBuilder.CreateTable(
                name: "Country",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true, comment: "国家名称"),
                    Code = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true, comment: "国家代码"),
                    CreatedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
                    UpdatedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Country", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DataConfig",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Key = table.Column<string>(type: "TEXT", nullable: true, comment: "唯一标识Key"),
                    PKey = table.Column<string>(type: "TEXT", nullable: true, comment: "PKey"),
                    Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true, comment: "名称"),
                    Value = table.Column<string>(type: "TEXT", nullable: true, comment: "值"),
                    Value2 = table.Column<string>(type: "TEXT", nullable: true, comment: "值扩展"),
                    Value3 = table.Column<string>(type: "TEXT", nullable: true, comment: "值3"),
                    Value4 = table.Column<string>(type: "TEXT", nullable: true, comment: "值4"),
                    Value5 = table.Column<string>(type: "TEXT", nullable: true, comment: "值5"),
                    GroupName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true, comment: "分组"),
                    Sort = table.Column<int>(type: "INTEGER", nullable: false, comment: "排序"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否启用"),
                    Remark = table.Column<string>(type: "TEXT", nullable: true, comment: "备注"),
                    ExtensionData = table.Column<string>(type: "TEXT", nullable: true, comment: "扩展参数"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DataConfig", x => x.Id);
                },
                comment: "数据配置");

            migrationBuilder.CreateTable(
                name: "EmailSend",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    TypeCode = table.Column<string>(type: "TEXT", nullable: true),
                    Subject = table.Column<string>(type: "TEXT", nullable: true, comment: "主题"),
                    Content = table.Column<string>(type: "TEXT", nullable: true, comment: "内容"),
                    ReceiveName = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true, comment: "收件人"),
                    ReceiveEmail = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true, comment: "收件邮箱"),
                    SenderName = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true, comment: "发件人"),
                    SenderEmail = table.Column<string>(type: "TEXT", maxLength: 2000, nullable: true, comment: "发件邮箱"),
                    State = table.Column<int>(type: "INTEGER", nullable: false, comment: "发送状态"),
                    SourceId = table.Column<int>(type: "INTEGER", nullable: true, comment: "来源ID"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EmailSend", x => x.Id);
                },
                comment: "邮件发送记录");

            migrationBuilder.CreateTable(
                name: "EmailTemplate",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Code = table.Column<string>(type: "TEXT", nullable: true, comment: "邮件模板代码"),
                    Content = table.Column<string>(type: "TEXT", nullable: true, comment: "模板内容"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否启用"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EmailTemplate", x => x.Id);
                },
                comment: "邮件模板");

            migrationBuilder.CreateTable(
                name: "IpBlackList",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    IpAddress = table.Column<string>(type: "TEXT", nullable: true, comment: "IP地址"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否启用"),
                    Type = table.Column<int>(type: "INTEGER", nullable: false, comment: "IP地址类型"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IpBlackList", x => x.Id);
                },
                comment: "IP黑名单");

            migrationBuilder.CreateTable(
                name: "Notepad",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Title = table.Column<string>(type: "TEXT", nullable: true, comment: "标题"),
                    Content = table.Column<string>(type: "TEXT", nullable: true, comment: "内容"),
                    SourceId = table.Column<int>(type: "INTEGER", nullable: true, comment: "来源ID"),
                    ExtensionData = table.Column<string>(type: "TEXT", nullable: true, comment: "扩展json数据字段"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Notepad", x => x.Id);
                },
                comment: "记事本");

            migrationBuilder.CreateTable(
                name: "Notice",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    TypeCode = table.Column<string>(type: "TEXT", nullable: true, comment: "通知类型代码"),
                    Title = table.Column<string>(type: "TEXT", nullable: true, comment: "标题"),
                    Content = table.Column<string>(type: "TEXT", nullable: true, comment: "内容"),
                    IsRead = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否读取"),
                    ReadTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "读取状态"),
                    UserId = table.Column<int>(type: "INTEGER", nullable: false, comment: "用户ID"),
                    ExtensionData = table.Column<string>(type: "TEXT", nullable: true, comment: "扩展json数据字段"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Notice", x => x.Id);
                },
                comment: "通知");

            migrationBuilder.CreateTable(
                name: "RegionInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Code = table.Column<string>(type: "TEXT", nullable: true),
                    SuperiorCode = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    ShortName = table.Column<string>(type: "TEXT", nullable: true),
                    FullName = table.Column<string>(type: "TEXT", nullable: true),
                    Lng = table.Column<string>(type: "TEXT", nullable: true),
                    Lat = table.Column<string>(type: "TEXT", nullable: true),
                    Sort = table.Column<int>(type: "INTEGER", nullable: false),
                    Remark = table.Column<string>(type: "TEXT", nullable: true),
                    State = table.Column<int>(type: "INTEGER", nullable: false),
                    TenantCode = table.Column<string>(type: "TEXT", nullable: true),
                    Level = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RegionInfo", x => x.Id);
                },
                comment: "地区信息");

            migrationBuilder.CreateTable(
                name: "SmsSend",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    TypeCode = table.Column<string>(type: "TEXT", nullable: true),
                    Content = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true, comment: "内容"),
                    Receive = table.Column<string>(type: "TEXT", maxLength: 11, nullable: true, comment: "接收号码"),
                    ReceiveName = table.Column<string>(type: "TEXT", nullable: true, comment: "接收用户名称"),
                    State = table.Column<int>(type: "INTEGER", nullable: false, comment: "发送状态(待发送 = 0,发送成功 = 1,发送失败 = 2)"),
                    ExpireTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "过期时间"),
                    IsUse = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否使用"),
                    UseTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "使用时间"),
                    SourceId = table.Column<int>(type: "INTEGER", nullable: true, comment: "来源ID"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SmsSend", x => x.Id);
                },
                comment: "短信发送记录");

            migrationBuilder.CreateTable(
                name: "SmsTemplate",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Content = table.Column<string>(type: "TEXT", nullable: true),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SmsTemplate", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Web.Menu",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    MId = table.Column<string>(type: "TEXT", nullable: true, comment: "菜单ID"),
                    PMId = table.Column<string>(type: "TEXT", nullable: true, comment: "父Id"),
                    Name = table.Column<string>(type: "TEXT", nullable: true, comment: "菜单名称"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否可用"),
                    Icon = table.Column<string>(type: "TEXT", nullable: true, comment: "图标"),
                    Sort = table.Column<int>(type: "INTEGER", nullable: false, comment: "顺序"),
                    Url = table.Column<string>(type: "TEXT", nullable: true, comment: "Url"),
                    OpenType = table.Column<int>(type: "INTEGER", nullable: false),
                    Remark = table.Column<string>(type: "TEXT", nullable: true, comment: "备注"),
                    IsExpand = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否展开菜单"),
                    MenuType = table.Column<int>(type: "INTEGER", nullable: false, comment: "节点类型(菜单、工具栏)"),
                    IsDisuse = table.Column<bool>(type: "INTEGER", nullable: false),
                    IsSystem = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否系统菜单"),
                    IsShow = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否显示"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.Menu", x => x.Id);
                },
                comment: "菜单表");

            migrationBuilder.CreateTable(
                name: "Web.Permission",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    TypeCode = table.Column<string>(type: "TEXT", nullable: true, comment: "类型代码"),
                    Controller = table.Column<string>(type: "TEXT", nullable: true, comment: "控制器"),
                    ControllerDescription = table.Column<string>(type: "TEXT", nullable: true, comment: "控制器描述"),
                    Name = table.Column<string>(type: "TEXT", nullable: true, comment: "名称"),
                    Actions = table.Column<string>(type: "TEXT", nullable: true, comment: "方法/Action名称,多个用英文逗号隔开"),
                    Remark = table.Column<string>(type: "TEXT", nullable: true, comment: "备注"),
                    IsSystem = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否系统菜单"),
                    IsDisuse = table.Column<bool>(type: "INTEGER", nullable: false),
                    IsAutoGeneration = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否自动生成"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.Permission", x => x.Id);
                },
                comment: "功能/Action");

            migrationBuilder.CreateTable(
                name: "Web.Role",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Code = table.Column<string>(type: "TEXT", nullable: true, comment: "标识"),
                    Name = table.Column<string>(type: "TEXT", nullable: true, comment: "名称"),
                    Sort = table.Column<int>(type: "INTEGER", nullable: false, comment: "排序"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否启用"),
                    Remark = table.Column<string>(type: "TEXT", nullable: true, comment: "备注"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.Role", x => x.Id);
                },
                comment: "角色");

            migrationBuilder.CreateTable(
                name: "Web.User",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    Account = table.Column<string>(type: "TEXT", nullable: true, comment: "用户名"),
                    Pwd = table.Column<string>(type: "TEXT", nullable: true, comment: "密码"),
                    UserType = table.Column<int>(type: "INTEGER", nullable: false, comment: "账户类型"),
                    IsEnable = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否启用"),
                    IsTest = table.Column<bool>(type: "INTEGER", nullable: false, comment: "是否测试"),
                    Nick = table.Column<string>(type: "TEXT", nullable: true, comment: "昵称"),
                    Email = table.Column<string>(type: "TEXT", nullable: true, comment: "邮箱"),
                    Province = table.Column<string>(type: "TEXT", nullable: true, comment: "省份"),
                    City = table.Column<string>(type: "TEXT", nullable: true, comment: "城市"),
                    Town = table.Column<string>(type: "TEXT", nullable: true, comment: "镇"),
                    Address = table.Column<string>(type: "TEXT", nullable: true, comment: "详细地址"),
                    Phone = table.Column<string>(type: "TEXT", nullable: true, comment: "联系电话"),
                    Tel = table.Column<string>(type: "TEXT", nullable: true, comment: "办公电话"),
                    Remark = table.Column<string>(type: "TEXT", nullable: true, comment: "备注"),
                    LastLoginTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "最后登录时间"),
                    LastLoginIp = table.Column<string>(type: "TEXT", nullable: true, comment: "最后登录IP"),
                    LastLoginUserAgent = table.Column<string>(type: "TEXT", nullable: true, comment: "最后登录用户浏览器信息"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间"),
                    UpdateUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "更新用户ID"),
                    UpdateUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "更新用户"),
                    UpdateTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "更新时间"),
                    IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false, comment: "默认假删除"),
                    DeletedUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "删除用户ID"),
                    DeletedUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "删除用户"),
                    DeletedTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.User", x => x.Id);
                },
                comment: "用户表");

            migrationBuilder.CreateTable(
                name: "WebVisitLog",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false, comment: "ID")
                        .Annotation("Sqlite:Autoincrement", true),
                    RemoteAddr = table.Column<string>(type: "TEXT", nullable: true, comment: "远程地址，IP地址"),
                    RequestUrl = table.Column<string>(type: "TEXT", nullable: true, comment: "请求地址"),
                    Method = table.Column<string>(type: "TEXT", nullable: true, comment: "请求方法"),
                    Params = table.Column<string>(type: "TEXT", nullable: true, comment: "请求参数"),
                    Exception = table.Column<string>(type: "TEXT", nullable: true, comment: "异常信息"),
                    LogContent = table.Column<string>(type: "TEXT", nullable: true, comment: "日志内容"),
                    Tag = table.Column<string>(type: "TEXT", nullable: true, comment: "关键词，多个用英文逗号隔开,方便查询用"),
                    Type = table.Column<string>(type: "TEXT", nullable: true, comment: "日志类型"),
                    Par1 = table.Column<string>(type: "TEXT", nullable: true, comment: "参数1"),
                    Par2 = table.Column<string>(type: "TEXT", nullable: true, comment: "参数2"),
                    Par3 = table.Column<string>(type: "TEXT", nullable: true, comment: "参数3"),
                    UserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "用户Id"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WebVisitLog", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Web.MenuPermission",
                columns: table => new
                {
                    MenuId = table.Column<int>(type: "INTEGER", nullable: false, comment: "菜单Id"),
                    PermissionId = table.Column<int>(type: "INTEGER", nullable: false, comment: "功能/权限Id"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.MenuPermission", x => new { x.PermissionId, x.MenuId });
                    table.ForeignKey(
                        name: "FK_Web.MenuPermission_Web.Menu_MenuId",
                        column: x => x.MenuId,
                        principalTable: "Web.Menu",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Web.MenuPermission_Web.Permission_PermissionId",
                        column: x => x.PermissionId,
                        principalTable: "Web.Permission",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                },
                comment: "功能/Action");

            migrationBuilder.CreateTable(
                name: "Web.RolePermission",
                columns: table => new
                {
                    RoleId = table.Column<int>(type: "INTEGER", nullable: false, comment: "角色Id"),
                    PermissionId = table.Column<int>(type: "INTEGER", nullable: false, comment: "功能/权限Id"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.RolePermission", x => new { x.PermissionId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_Web.RolePermission_Web.Permission_PermissionId",
                        column: x => x.PermissionId,
                        principalTable: "Web.Permission",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Web.RolePermission_Web.Role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Web.Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "角色权限/角色功能");

            migrationBuilder.CreateTable(
                name: "Web.UserRole",
                columns: table => new
                {
                    UserId = table.Column<int>(type: "INTEGER", nullable: false, comment: "用户Id"),
                    RoleId = table.Column<int>(type: "INTEGER", nullable: false, comment: "角色Id"),
                    CreatorUserId = table.Column<int>(type: "INTEGER", nullable: true, comment: "创建用户ID"),
                    CreatorUserName = table.Column<string>(type: "TEXT", nullable: true, comment: "创建用户"),
                    CreationTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Web.UserRole", x => new { x.UserId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_Web.UserRole_Web.Role_RoleId",
                        column: x => x.RoleId,
                        principalTable: "Web.Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Web.UserRole_Web.User_UserId",
                        column: x => x.UserId,
                        principalTable: "Web.User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户角色");

            migrationBuilder.InsertData(
                table: "DataConfig",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "ExtensionData", "GroupName", "IsDeleted", "IsEnable", "Key", "Name", "PKey", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Value", "Value2", "Value3", "Value4", "Value5" },
                values: new object[] { 1, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 489, DateTimeKind.Unspecified).AddTicks(2779), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, null, null, false, false, "SystemSetting", "系统设置", "", null, 0, null, null, null, "", null, null, null, null });

            migrationBuilder.InsertData(
                table: "DataConfig",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "ExtensionData", "GroupName", "IsDeleted", "IsEnable", "Key", "Name", "PKey", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Value", "Value2", "Value3", "Value4", "Value5" },
                values: new object[] { 2, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 489, DateTimeKind.Unspecified).AddTicks(4753), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, null, null, false, false, "EmailSetting", "邮件设置", "", null, 0, null, null, null, "", null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 1, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(3521), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-set-fill", false, false, false, false, false, false, "SystemManager", 0, "系统管理", 0, "", null, 1, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 2, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(6909), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-user", false, false, false, false, false, false, "UserManager", 0, "用户管理", 0, "", null, 2, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 3, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(6922), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-log", false, false, false, false, false, false, "LogRecord", 0, "日志记录", 0, "", null, 5, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 4, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(6924), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-chart", false, false, false, false, false, false, "StatisticsManager", 0, "数据统计", 0, "", null, 6, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 5, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(6927), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-util", false, false, false, false, false, false, "DeveloperManager", 0, "开发工具", 0, "", null, 7, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.Menu",
                columns: new[] { "Id", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Icon", "IsDeleted", "IsDisuse", "IsEnable", "IsExpand", "IsShow", "IsSystem", "MId", "MenuType", "Name", "OpenType", "PMId", "Remark", "Sort", "UpdateTime", "UpdateUserId", "UpdateUserName", "Url" },
                values: new object[] { 11000, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 448, DateTimeKind.Unspecified).AddTicks(6932), new TimeSpan(0, 8, 0, 0, 0)), null, null, null, null, null, "layui-icon layui-icon-util", false, false, false, false, false, false, "API", 2, "API接口", 0, "", null, 1, null, null, null, null });

            migrationBuilder.InsertData(
                table: "Web.User",
                columns: new[] { "Id", "Account", "Address", "City", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Email", "IsDeleted", "IsEnable", "IsTest", "LastLoginIp", "LastLoginTime", "LastLoginUserAgent", "Nick", "Phone", "Province", "Pwd", "Remark", "Tel", "Town", "UpdateTime", "UpdateUserId", "UpdateUserName", "UserType" },
                values: new object[] { 1, "developer", null, null, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 475, DateTimeKind.Unspecified).AddTicks(8104), new TimeSpan(0, 8, 0, 0, 0)), 0, "", null, null, null, null, false, false, false, null, null, null, "超级管理员", null, null, "kzaHyaxE8kmRCl7e0rMTGgEXDDYlC4A/hD38dIheD9kCBtS8bKOODe0Se8rPEe4dfDwPl17lya9hwsyzauz2UBN/ENkv2sZ5bpt+eKHl9klp", null, null, null, null, null, null, 99 });

            migrationBuilder.InsertData(
                table: "Web.User",
                columns: new[] { "Id", "Account", "Address", "City", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Email", "IsDeleted", "IsEnable", "IsTest", "LastLoginIp", "LastLoginTime", "LastLoginUserAgent", "Nick", "Phone", "Province", "Pwd", "Remark", "Tel", "Town", "UpdateTime", "UpdateUserId", "UpdateUserName", "UserType" },
                values: new object[] { 2, "administrator", null, null, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 476, DateTimeKind.Unspecified).AddTicks(76), new TimeSpan(0, 8, 0, 0, 0)), 0, "", null, null, null, null, false, false, false, null, null, null, "超级管理员", null, null, "RBDhSMHXIUe532P+ERiqZgExmlNjVkvrM0lOjJwNYV10tJRjYFnJSc2Zn5oDEeIuu2kJyjU65WcvY5od2fGmnn7+GZZPelvSDMeUs1lHFGiW", null, null, null, null, null, null, 99 });

            migrationBuilder.InsertData(
                table: "Web.User",
                columns: new[] { "Id", "Account", "Address", "City", "CreationTime", "CreatorUserId", "CreatorUserName", "DeletedTime", "DeletedUserId", "DeletedUserName", "Email", "IsDeleted", "IsEnable", "IsTest", "LastLoginIp", "LastLoginTime", "LastLoginUserAgent", "Nick", "Phone", "Province", "Pwd", "Remark", "Tel", "Town", "UpdateTime", "UpdateUserId", "UpdateUserName", "UserType" },
                values: new object[] { 3, "testuser", null, null, new DateTimeOffset(new DateTime(2021, 4, 20, 10, 36, 51, 476, DateTimeKind.Unspecified).AddTicks(83), new TimeSpan(0, 8, 0, 0, 0)), 0, "", null, null, null, null, false, false, false, null, null, null, "测试用户", null, null, "2nw+PMMy8kCSNziGmn/IhgEV/YW0QPE3XuP95AO+HRmEttVWz8SiC4hZQGvVfG/Qzb1NB8Fmfj4s7D8evhEAN9MFTTcR8AK0Nr/zJiT4n3wK", null, null, null, null, null, null, 0 });

            migrationBuilder.CreateIndex(
                name: "IX_Web.MenuPermission_MenuId",
                table: "Web.MenuPermission",
                column: "MenuId");

            migrationBuilder.CreateIndex(
                name: "IX_Web.Role_Name",
                table: "Web.Role",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_Web.RolePermission_RoleId",
                table: "Web.RolePermission",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_Web.User_Account_UserType",
                table: "Web.User",
                columns: new[] { "Account", "UserType" });

            migrationBuilder.CreateIndex(
                name: "IX_Web.User_Email_Phone",
                table: "Web.User",
                columns: new[] { "Email", "Phone" });

            migrationBuilder.CreateIndex(
                name: "IX_Web.User_Tel_Nick",
                table: "Web.User",
                columns: new[] { "Tel", "Nick" });

            migrationBuilder.CreateIndex(
                name: "IX_Web.UserRole_RoleId",
                table: "Web.UserRole",
                column: "RoleId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AutidLog");

            migrationBuilder.DropTable(
                name: "Country");

            migrationBuilder.DropTable(
                name: "DataConfig");

            migrationBuilder.DropTable(
                name: "EmailSend");

            migrationBuilder.DropTable(
                name: "EmailTemplate");

            migrationBuilder.DropTable(
                name: "IpBlackList");

            migrationBuilder.DropTable(
                name: "Notepad");

            migrationBuilder.DropTable(
                name: "Notice");

            migrationBuilder.DropTable(
                name: "RegionInfo");

            migrationBuilder.DropTable(
                name: "SmsSend");

            migrationBuilder.DropTable(
                name: "SmsTemplate");

            migrationBuilder.DropTable(
                name: "Web.MenuPermission");

            migrationBuilder.DropTable(
                name: "Web.RolePermission");

            migrationBuilder.DropTable(
                name: "Web.UserRole");

            migrationBuilder.DropTable(
                name: "WebVisitLog");

            migrationBuilder.DropTable(
                name: "Web.Menu");

            migrationBuilder.DropTable(
                name: "Web.Permission");

            migrationBuilder.DropTable(
                name: "Web.Role");

            migrationBuilder.DropTable(
                name: "Web.User");
        }
    }
}
